package org.example.Swing.xiangmu.login;

import org.example.Swing.handler.AddKcHandler;

import javax.swing.*;
import java.awt.*;

public class AddKcView extends JDialog {
    JPanel jPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 20));
    JLabel keLabel = new JLabel("课程名称:", JLabel.RIGHT);
    JTextField keTxt = new JTextField();

    JButton addkcBtn = new JButton("添加课程");
    AddKcHandler addKcHandler;

    public AddKcView(AddView addView) {
        super(addView, "添加课程");

        addKcHandler = new AddKcHandler(this, addView);


        keLabel.setPreferredSize(new Dimension(80, 30));
        jPanel.add(keLabel);
        keTxt.setPreferredSize(new Dimension(200, 30));
        jPanel.add(keTxt);

        addkcBtn.addActionListener(addKcHandler);
        jPanel.add(addkcBtn);

        Container contentPane = getContentPane();
        contentPane.add(jPanel);

        setSize(350, 500);
        setLocationRelativeTo(null);
        // DISPOSE_ON_CLOSE:只销毁当前的窗体
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        setResizable(false);
        setVisible(true);
    }

    public JTextField getKeTxt() {
        return keTxt;
    }

}

